How can I delete users from a schedule via the API?

To delete a user from a schedule through the API, you will want to update the schedule and include all of the users in the users array who are currently on the schedule, minus the user(s) that you’re looking to remove.

I’m trying to delete a user from a schedule via the API. I first get the schedule using the API. Then I use the get schedule response to build the request body for the update schedule API removing the user references in the schedule.users array and the schedule.schedule_layers[].users array(s). I get a 200 status form the API and the response body sows the user is no longer in the schedule. However when I look at the schedule in the web UI I see the user is still in the schedule. Also, if I try to delete the user via the API the response shows the user is still in the schedule.

Should the response from get schedule not be used for the update as I’m doing? Are their properties I should no be including?

Thanks

Hi Steve,

The response body from the ‘Get a schedule’ API call can be used for the ‘Update a schedule’ API request call. If you want to delete a user, then you have to remove the specific JSON for the user under the schedule.users array, as you have mentioned.

A possibility why you still see the user in the web UI is because you are viewing a time in the past where the (now) deleted user was still on the schedule.

But for us to investigate further, could you please write in to support@pagerduty.com with the response body from the ‘Update a schedule’ API request call, as well as the name of the deleted user so that we can further assist you?

Thanks,
Jay

Hi Jay, will do.

Steve